<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch"
          data-options="{searchDatagrid:$.CurrentNavtab.find('#investaAdviserTable')}">
        <fieldset>
            <legend style="font-weight:normal;">搜索：</legend>

            <div class="bjui-row col-3">
                <label class="row-label">顾问姓名:</label>
                <div class="row-input">
                    <input type="text" name="name" class="form-control" size="30" title="顾问姓名">
                </div>

                <label class="row-label">顾问编号：</label>
                <div class="row-input">
                    <input type="text" name="numb" class="form-control" size="30" title="顾问编号">
                </div>

                <label class="row-label">顾问电话：</label>
                <div class="row-input">
                    <input type="text" name="phone" class="form-control" size="30" title="顾问电话">
                </div>


                <label class="row-label">注册时间：</label>
                <div class="row-input">
                    <input type="text" name="dateFromTo.from" data-toggle="datepicker" data-nobtn="true" size="14">
                    -
                    <input type="text" name="dateFromTo.to" data-toggle="datepicker" data-nobtn="true" size="14">
                </div>


                <label class="row-label">排序：</label>
                <div class="row-input">
                    <select name="sortAddTime" title="排序" data-toggle="selectpicker" data-width="300">
                        <option value="addTime,1">注册时间正序</option>
                        <option value="addTime,-1">注册时间倒序</option>
                    </select>
                </div>


                <label class="row-label"></label>
                <div class="row-input">
                    <div class="btn-group">
                        <button type="submit" class="btn-green" data-icon="search">搜索</button>
                        <button type="reset" class="btn-orange" data-icon="times">重置</button>
                        <button type="button" class="btn btn-green" onclick="investaAdviserListExport();"
                                data-icon="sign-out"><i class="fa fa-sign-out"></i> 导出
                        </button>
                    </div>
                </div>

            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table id="investaAdviserTable" class="table table-bordered">
    </table>
</div>

<script type="text/javascript" src="/js/toolDate.js"></script>
<script type="text/javascript">

    function updataColumns(value, data) {
        var htmlstr = '<button type="button" class="btn-green" onclick="check(\'' + data.id + '\');">修改</button>'
        return htmlstr;
    }


    function check(id) {
        if (!id) return;

        var openURL = "/admin/salesman/investaadviser/upInvestaAdviserView?id=" + id;

        BJUI.dialog({
            id: 'upInvestaAdviser',
            url: openURL,
            title: '修改',
            resizeable: true,
            fresh: true,
            height:320,
            onClose: function () {
                BJUI.navtab('refresh');
            }
        });
    }


    $(function () {
        $("#investaAdviserTable").datagrid({
            height: '100%',
            tableWidth: '99%',
            showToolbar: false,
            filterThead: false,
            dataUrl: '/admin/salesman/investaadviser/selInvestaAdvisers',
            local: "remote",
            inlineEditMult: false,
            delConfirm: true,
            columns: [
                {
                    label: "顾问姓名",
                    name: "name",
                    align: "center"
                },
                {
                    label: "顾问编号",
                    name: "numb",
                    align: "center"
                },
                {
                    label: "顾问手机",
                    name: "phone",
                    align: "center"
                },
                {
                    label: "备注",
                    name: "remarks",
                    align: "center"
                },
                {
                    label: "添加时间",
                    name: "addTime",
                    align: "center"
                },
                {
                    label: '操作列',
                    render: updataColumns,
                    align: "center"
                }
            ],
            paging: {pageSize: 15, pageIndex: 1},
            linenumberAll: true,
            showCheckboxcol: true
        });

    });


    function investaAdviserListExport() {
        var dates = $(investaAdviserTable).data('selectedDatas');
        if (dates && dates.length !== 0) {
            var ids = [];
            dates.forEach(function (e) {
                ids.push(e.id);
            });
            BJUI.ajax('ajaxdownload', {
                url: '/admin/salesman/investaadviser/excelInvestaAdvisers',
                data: {ids: ids.join(",")}
            });
        } else
            BJUI.alertmsg('info', BJUI.getRegional('datagrid.selectMsg'))
    }
</script>